package com.int_tech.station.dao;

import com.int_tech.mession.entity.Mession;
import com.int_tech.station.entity.Station;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by Administrator on 2017/9/22.
 */
public interface StationDao extends JpaRepository<Station,Integer>,JpaSpecificationExecutor<Station> {
    List<Station> findStationByClientIdAndIsDel(int client, int isDel);
    List<Station> findStationByIsDel(int isDel);
    List<Station> findStationByIsDel(Pageable pageable,int isDel);
    Station findStationByNameAndIsDel(String name,int isDel);
    Station findStationByNameAndClientId(String name,int clentId);
    List<Station> findByClientId(int clientId);
    Page<Station> findByClientIdAndIsDel(Pageable pageable,int clentId,int isDel);
    Page<Station> findByIsDel(Pageable pageable,int isDel);

    Station findByClientIdAndNameAndIsDel(int clentId,String name,int isDel);
    @Query("select s from Station s where s.name like CONCAT('%',:name,'%')")
    List<Station> findByNameLike(String name);

    @Query("select s from Station s where s.name like CONCAT('%',:name,'%') and s.clientId =:clientId")
    List<Station> findByClientIdAndNameLike(int clientId, String text);
    Station findByNameAndClientId(String name,int isDel);

    Station findById(Integer stationId);
}
